package com.example.foobar.dao.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.foobar.entity.ImsGhostQrcodeRecords;
import com.example.foobar.mapper.ImsGhostQrcodeRecordsMapper;
import com.example.foobar.dao.service.ImsGhostQrcodeRecordsDaoService;
import com.example.foobar.param.ImsGhostQrcodeRecordsPageParam;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

/**
 *  服务实现类
 *
 * @author 郑英奔
 * @since 2021-07-15
 */
@Slf4j
@Service
@DS("db1")
public class ImsGhostQrcodeRecordsDaoServiceImpl extends BaseServiceImpl<ImsGhostQrcodeRecordsMapper, ImsGhostQrcodeRecords> implements ImsGhostQrcodeRecordsDaoService {

    @Autowired
    private ImsGhostQrcodeRecordsMapper imsGhostQrcodeRecordsMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean saveImsGhostQrcodeRecords(ImsGhostQrcodeRecords imsGhostQrcodeRecords)  {
        return super.save(imsGhostQrcodeRecords);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean updateImsGhostQrcodeRecords(ImsGhostQrcodeRecords imsGhostQrcodeRecords)  {
        return super.updateById(imsGhostQrcodeRecords);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean deleteImsGhostQrcodeRecords(Long id)  {
        return super.removeById(id);
    }

    @Override
    public Paging<ImsGhostQrcodeRecords> getImsGhostQrcodeRecordsPageList(ImsGhostQrcodeRecordsPageParam imsGhostQrcodeRecordsPageParam)  {
        Page<ImsGhostQrcodeRecords> page = new PageInfo<>(imsGhostQrcodeRecordsPageParam, OrderItem.desc(getLambdaColumn(ImsGhostQrcodeRecords::getCreateTime)));
        LambdaQueryWrapper<ImsGhostQrcodeRecords> wrapper = new LambdaQueryWrapper<>();
        IPage<ImsGhostQrcodeRecords> iPage = imsGhostQrcodeRecordsMapper.selectPage(page, wrapper);
        return new Paging<ImsGhostQrcodeRecords>(iPage);
    }

}
